package com.yuanjin.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yuanjin.R;
import com.yuanjin.models.Map_MyLocation;

public class Map_MylocationAdapter<T> extends BaseAdapter {
	private Context context;
	private List<T> list;
	private LayoutInflater minflater; 

	public Map_MylocationAdapter(Context context,List<T>list) {
		this.context=context;
		this.minflater=LayoutInflater.from(context);
		this.list=list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView=null;
		if (convertView==null) {
			rowView=minflater.inflate(R.layout.item_mylocation_list, null);
		}else {
			rowView=convertView;
		}
		TextView tv_id = (TextView) rowView.findViewById(R.id.tv_id);
		TextView tv_name = (TextView) rowView.findViewById(R.id.tv_name);
		TextView tv_time = (TextView) rowView.findViewById(R.id.tv_time);
		TextView tv_lat = (TextView) rowView.findViewById(R.id.tv_lat);
		TextView tv_lon = (TextView) rowView.findViewById(R.id.tv_lon);
		Map_MyLocation myLocation=(Map_MyLocation) getItem(position);
		tv_id.setText((position+1)+".");
		tv_name.setText(myLocation.getAddress());
		tv_time.setText(myLocation.getTime());
		tv_lat.setText(myLocation.getLat()+"");
		tv_lon.setText(myLocation.getLon()+"");

		return rowView;
	}

}
